package com.cloudlead.fleetAction.action;

import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.lang.persistence.ObjectList;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.fleetAction.BusinessModules;
import com.cloudlead.fleetAction.service.BaseDriverEditSer;
import com.cloudlead.fleetService.BaseDriverEditService;
import com.cloudlead.fleetService.vo.BaseDriverVO;
import com.cloudlead.fleetService.vo.BaseFleetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by 123 on 2015/9/1.
 */
@Controller
public class BaseDriverEditActionFactory extends AbstractActionFactory implements BaseDriverEditService {

    @Autowired
    BaseDriverEditSer baseDriverEditSer;

    public BaseDriverEditActionFactory() {
        super(BusinessModules.DriverManagement);
    }


    @Action
    @Order(1)
    @Label("增加驾驶员")
    public void addBaseDriver(BaseDriverVO baseDriverVO) {
        baseDriverEditSer.addBaseDriver(baseDriverVO);
    }

    @Override
    @Action
    @Order(2)
    @Label("删除驾驶员")
    public void delBaseDriver(@Label("ID")String id) {
        baseDriverEditSer.delBaseDriver(id);
    }

    @Override
    @Action
    @Order(8)
    @Label("恢复驾驶员")
    public void hfBaseDriver(String id) {
        baseDriverEditSer.hfBaseDriver(id);
    }

    @Override
    @Action
    @Order(3)
    @Label("修改驾驶员")
    public void editBaseDriver(BaseDriverVO baseDriverVO) {
        baseDriverEditSer.editBaseDriver(baseDriverVO);
    }

    @Override
    @Action
    @Order(4)
    @Label("驾驶员单值查询")
    public Object findBaseDriver(BaseDriverVO baseDriverVO) {

        return baseDriverEditSer.findOneBaseDriver(baseDriverVO);
    }

    @Override
    @Action
    @Order(7)
    @Label("微信解绑")
    public void relieveWX(String id) {
        baseDriverEditSer.relieveWX(id);
    }

    @Override
    @Action
    @Order(5)
    @Label("驾驶员分页查询")
    public EasyuiGridData findAllBaseDriver(BaseDriverVO vo,
                                                @Label("每页的数量")int rows,@Label("页码")int page) {
        return new EasyuiGridData( baseDriverEditSer.findAllBaseDriver(vo,rows,page),"id,name,identityCard," +
                "baseFleet.fleetName fleetName,baseCompany.companyName companyName,baseFleet.id fleetId ,mobile,drivingLicence,limitedDate,openId,password");
    }

    @Override
    @Action
    @Order(6)
    @Label("驾驶员列表")
    public ObjectList baseDriverList(@Label("公司ID")@NotNull String baseCompanyId) {
        return new ObjectList( baseDriverEditSer.baseDriverList(baseCompanyId),"id,name");
    }
    @Override
    @Action
    @Order(6)
    @Label("按车队查询驾驶员")
    public ObjectList baseDriverListByFleet(String fleetId) {
        return new ObjectList( baseDriverEditSer.baseDriverListByFleet(fleetId), "id,name");
    }
}
